import requests
import json
import re

def extract_urls(text): #输入respone,寻找网址,返回列表urls
    url_pattern = re.compile(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+')
    urls = url_pattern.findall(text)
    return urls


def findvalue(respon): #输入respond,判断单仓多仓，返回cang自定义文本
    mcang="storeHouse"
    scang="{\"urls\""
    xlu="spider"

    if respon.find(mcang) != -1:
        cang = "H多仓"#+ respon.find(mcang)
    elif respon.find(scang) != -1:
        cang="H单仓" #+respon.find(scang)
    elif respon.find(xlu) != -1:
        cang="H线路"#+respon.find(xlu)
    else:
        cang="=_H_=不通畅"
    return cang

def addlink(url): #增加代理链接
    agentlink="http://fly.lyin.cf/?url="
    agentlink1="http://lige.unaux.com/?url="
    urll=agentlink1+url
    return urll

def re_findall(url): #返回respone
    respon=requests.get(addlink(url)).text
    return respon

#------------------------------------------
url1="http://rihou.vip:66/"
url2="http://xn--6orp08a.4tvbox.v6.navy/无敌.json"
url3="https://agit.ai/leevi/PiG/raw/branch/master/jsm.json"
url5="https://gitee.com/jiangnandao/tvboxline/raw/master/tvbox.json"
url6="http://530.my3v.work/xdck.json"
url7="https://cdn.jsdelivr.net/gh/GaiVmao/dianshiyuan@main/yuan2.txt"

urlink=addlink(url6) #增加代理链接
# urlink=url5
# print("代理路线是: "+urlink)

msx=findvalue(re_findall(urlink))  #判断单仓多仓,返回cang自定义文本
print(msx)
if msx=="H多仓":
    print("多仓zx: "+urlink)
elif msx=="H单仓":
    print("单仓zx: "+urlink)
    for url in extract_urls(re_findall(urlink)) : #寻找批量的列表网址
        print(addlink(url)+" -- "+findvalue(re_findall(addlink(url))))
    print("----\n")
elif msx=="H线路":
    print("线路通畅zx: "+urlink)
else:
    print("400吧 "+urlink)
